package com.xt.back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xt.back.entity.Reward;
import com.xt.back.mapper.RewardMapper;
import com.xt.back.service.IRewardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p>
 * 奖励信息表 服务实现类
 * </p>
 *
 * @author leotong
 * @since 2022-04-03
 */
@Service
@AllArgsConstructor
public class RewardServiceImpl extends ServiceImpl<RewardMapper, Reward> implements IRewardService {

    private final RewardMapper rewardMapper;

    @Override
    public Page<Reward> getRewardByPage(Reward reward) {
        Page<Reward> page=new Page<>(reward.pageNum,reward.pageSize);
        QueryWrapper<Reward> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda()
                .like(!Objects.equals(reward.getRewardName(),""),Reward::getRewardName,reward.getRewardName());
        return rewardMapper.selectPage(page,queryWrapper);
    }
}
